package com.shfl.models;

import com.alibaba.fastjson.JSON;

import java.util.List;
import java.util.Map;

public class ResultInfo {

    String result;

    public ResultInfo(Integer i, String str) {
        StringBuilder sb = new StringBuilder();

        String resultString = str;
        if (i == 0 || i == 1 || i == 2 || i == 10) {
           // resultString = resultMap.get("words_result").toString();
        }
        if (i == 4) {
           // resultString = resultMap.get("result").toString();
        }

        if (i == 5 || i == 6 || i == 7 || i == 8 || i == 9 || i == 10) {
            sb.append("功能暂未实现，敬请期待!");
            return;
        }
        //通用文字识别
        if (i == 0) {
            List<GeneralBasic> generalBasics = JSON.parseArray(resultString, GeneralBasic.class);
            for (GeneralBasic generalBasic : generalBasics) {
                sb.append(generalBasic.getWords());
                sb.append("\n");
            }

        }
        //通用文字识别（高精度版）
        if (i == 1) {
            List<AccurateBasic> accurateBasics = JSON.parseArray(resultString, AccurateBasic.class);
            for (AccurateBasic generalBasic : accurateBasics) {
                sb.append(generalBasic.getWords());
                sb.append("\n");
            }

        }
        //手写文字识别
        if (i == 2) {
            List<HouseholdRegisterBeen> householdRegisters = JSON.parseArray(resultString, HouseholdRegisterBeen.class);
            for (HouseholdRegisterBeen householdRegisterBeen : householdRegisters) {
                sb.append(householdRegisterBeen.getWords());
                sb.append("\n");
            }
        }
        //身份证识别
        if (i == 3) {
            List<IdCardBeen> idCards = JSON.parseArray("", IdCardBeen.class);
        }
        //银行卡识别
        if (i == 4) {
            BankCardBeen bankCards = JSON.parseObject(resultString, BankCardBeen.class);
            if (bankCards != null) {
                sb.append("银行卡卡号:" + bankCards.getBank_card_number());
                sb.append("\n");
                sb.append("银行名称:" + bankCards.getBank_name());
            } else {
                sb.append("请重新上传");
            }

        }
        //识别营业执照
        if (i == 5) {
            List<BusinessLicenseBeen> businessLicenses = JSON.parseArray("", BusinessLicenseBeen.class);
        }
        //护照识别
        if (i == 6) {
            List<PassPortBeen> passPorts = JSON.parseArray("", PassPortBeen.class);
        }
        //名片识别
        if (i == 7) {
            List<BusinessCardBeen> businessCards = JSON.parseArray("", BusinessCardBeen.class);
        }
        //户口识别
        if (i == 8) {
            List<HouseholdRegisterBeen> householdRegisters = JSON.parseArray("", HouseholdRegisterBeen.class);
        }
        //通用票据识别
        if (i == 9) {
            List<ReceiptBeen> receipts = JSON.parseArray("", ReceiptBeen.class);
        }
        //增值税发票识别
        if (i == 10) {
            VatInvoiceBeen vatInvoice = JSON.parseObject(resultString, VatInvoiceBeen.class);
            if (vatInvoice != null) {

            } else {
                sb.append("请重新上传");
            }
        }

        this.result = sb.toString();
    }


    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }
}
